import re


with open('static/html/index.html','r',encoding='utf-8') as f:
    html = re.sub('\n', '' , f.read())
    # print(html)
    patten_section = '<section class="main_section">(.*?)</section>'
    sections = re.findall(patten_section,html)
    print(len(sections))
    patten_h1 = '<h1>(.*?)</h1>'
    patten_span = '<span class="course_name">(.*?)</span>'
    patten_price = '<span class="price">(.*?)</span>'

    datas=[]
    for section in sections:
        category = re.findall(patten_h1,section)[0]
        courses = re.findall(patten_span,section)
        prices = re.findall(patten_price,section)
        # print(courses,prices)
        courses_new=[]
        for i in range(0,len(courses)):
            courses_new.append(courses[i]+'  '+prices[i])
        print(courses_new)
        datas.append(
            {
            'category': category,
            'courses':courses_new

            }
        )

    print(datas)
    for data in datas:
        print(data.get('category'))
        for course  in data.get('courses'):
            print('    ',course)